package SEApp.boxes.albums
{
	import SEApp.se_util;
	
	import UIFree.controls.uif_label;
	import UIFree.uif_component;
	
	import flash.geom.Rectangle;

	public class se_userAvatar extends se_previewItem {
		protected var _label: uif_label;
		public function se_userAvatar(parent:uif_component, ax:int=0, ay:int=0, 
									awidth:int=0, aheight:int=0, userData: Object=null, 
									styleClass:String='') {
			super(parent, ax, ay, awidth, aheight, userData, styleClass);
			if (imageURL) _prevImage.loadSource(imageURL);
			if (text) {
				_label = new uif_label(this, _prevImage.x, _prevImage.y + _prevImage.height, _prevImage.width, 30, 'userAvatar');
				_label.text = text;
			}
		}
		
		protected function get imageURL(): String {
			return (_dataItem)?_dataItem.pic:null;
		}
		
		protected function get text(): String {
			return (_dataItem && _dataItem.first_name)?se_util.userName(_dataItem):'';
		}
		
		override protected function sourceRect(): Rectangle {
			var inner: Rectangle = getInner();
			inner.height -= 20;
			return inner;
		}
	}
}